from jose import jwt,JWTError

from app.core.config import settings


async def verify_device_token(token:str,dev_id:str) -> bool:
    """验证设备令牌"""
    try:
        payload = jwt.decode(token, settings.SECRET_KEY, algorithms=[settings.ALGORITHM])
        device_id:str = payload.get("dev_id")
        if device_id != dev_id:
            return False
        # 可以添加更多验证逻辑（如过期时间）
        return True
    except JWTError:
        return False
